<template>
  <div class="createTime">
    <el-input v-model="time" :placeholder="placeholder"></el-input>
    <el-date-picker @change="changeTime"   v-model="timePicker"
    type="datetimerange" range-separator="至"  :default-time="['00:00:00' , '23:59:59']" 
    start-placeholder="开始日期"  value-format="yyyy-MM-dd HH:mm:ss" end-placeholder="结束日期" placeholder="选择操作时间"></el-date-picker>
  </div>
</template>

<script>
export default {
  props: {
    placeholder: String,
    isClear: Boolean, //重置按钮点击
    params: String
  },
  data(){
    return{
      time: '',
      timePicker:''
    }
  },
  watch:{
    timePicker:function(n){
      if(n==null){
        this.time = ""
      }
    },
    isClear: function(){
      this.time = ""
      this.timePicker = ""
    }
  },
  methods:{
    changeTime (arr) {
      let str = null
      if(arr){
        str = arr[0] + ' - ' + arr[1]
        this.time = arr[0].split(' ')[0] +' - '+arr[1].split(' ')[0]
      }
      this.$emit("setData",this.params, str)
    },
    clearTimeValue(){
      this.time = ''
      this.timePicker = ''
    }
    
  }

}
</script>

<style>

</style>